Expand description
Erase pointers of their concrete type and store type-erased pointers.
This is roughly equivalent to C’s void*
.
There are two main useful reasons to type erase pointers in Rust:
- Removing viral generics from internal implementation details. If the internals truly don’t care about the stored type, treating it opaquely reduces monomorphization cost both to the author and the compiler.
- Thin pointers to
?Sized
types. If an unsized type stores its metadata inline, then it can implementErasable
and be used behind type-erased pointers. The type erased pointer does not have to carry the metadata, and the fat pointer can be recovered from the inline metadata. We provide theThin
wrapper type to provide thin pointer types.
Structs§
- Wrapper struct to create thin pointer types.
Traits§
- A pointee type that supports type-erased pointers (thin pointers).
- A (smart) pointer type that can be type-erased (making a thin pointer).
Functions§
- Erase a pointer.
Type Aliases§
- A thin, type-erased pointer.